export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: '考证',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1, initial-scalable=no' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      { rel: 'stylesheet', href: '/css/kz.css' },
      { rel: 'stylesheet', href: '/css/element-ui.css' }
    ],
    script: [
      { src: '/js/kz.js' }
    ]
  },

  // Delete data-n-head="ssr"
  hooks: {
    'render:route': (url, result) => {
      return result.html = result.html.replace(new RegExp(/data-n-head=\"ssr\" /, 'gi'), '');
    }
  },

  // Global call Middleware
  router: {
    middleware: 'auth'
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: ['@/plugins/element-ui'],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios', '@nuxtjs/proxy'
  ],

  axios: {
    proxy: true, // 表示开启代理
    prefix: '/', // 表示给请求url加个前缀 /api
    credentials: false // 表示跨域请求时是否需要使用凭证
  },

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  proxy: {
    '/api': {
      target: 'http://jpadmin.shfykj.com', // 线上API
      changeOrigin: true, // 表示是否跨域
      pathRewrite: {
        '^/api': '/', // 把 /api 替换成 /
      }
    }
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    transpile: [/^element-ui/],
  },
}
